package at.fhooe.mc.view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.Polygon;

import javax.swing.JPanel;

public class JTrianglePanelUp extends JPanel  {

    private Color trianglecolor = Color.lightGray;
    private boolean filled=false;
    private String targetFloorDown = "";

    public Color getTrianglecolor() {
        return trianglecolor;
    }

    public void setTrianglecolorOn(boolean on, String targetFloor) {

        filled = on;
        targetFloorDown = targetFloor;
        this.repaint();
    }


protected void paintComponent(Graphics g) {

    super.paintComponent(g);

    Point p1 = new Point(50,0);
    Point p2 = new Point(0,50);
    Point p3 = new Point(100,50);

    int[] xs = { p1.x, p2.x, p3.x };
    int[] ys = { p1.y, p2.y, p3.y };
    Polygon triangle = new Polygon(xs, ys, xs.length);

    if(filled){
    	trianglecolor = Color.lightGray;
    	g.setColor(trianglecolor);
        g.fillPolygon(triangle);
        g.setColor(Color.black);
        g.setFont(new Font("Helvetica", Font.PLAIN, 16));
        if(targetFloorDown == "10"){
        	 g.drawString(targetFloorDown.toString(), 40, 35);  //maybe needs to be corrected to look nice
        }else {
        	 g.drawString(targetFloorDown.toString(), 45, 35);
        }

    } else {
    	trianglecolor = Color.gray;
    	g.setColor(trianglecolor);
    	g.drawPolygon(triangle);
    }

    }

}
